typedef map<string, int, ics_less> valuemap

来源:百度知道 编辑:UC知道 时间:2024/05/30 04:39:45
定义了一个类:
Class XXX{
protected:
typedef map<string, int, ics_less> valuemap;
valuemap value_table;
在VC6.0下编译后出了问题,
: error C2143: syntax error : missing ';' before '<'
: error C2059: syntax error : '<'
: error C2238: unexpected token(s) preceding ';'
: error C2146: syntax error : missing ';' before identifier 'value_table'
: error C2501: 'valuemap' : missing storage-class or type specifiers
: error C2501: 'value_table' : missing storage-class or type specifiers
我现在一点头绪都没有,不知道到底哪里错了,对map也不是很熟悉 以前都没用过,请大家帮帮忙看看,不胜感激!
问题解决的 分数可以多给的,呵呵
虽然是在c++下编程,但用的很多都是c中的方法,我用了using namespace std以后就会报错,就算把#include的东西不加.h也会报错。。。

给个例子你参考下:
#include <map>
#include <iostream>

using namespace std;

int main()
{
typedef pair<int, int> IntPair;
map<int, int, greater<int> >::iterator iter;
map<int, int, greater<int> > m;
m.insert(IntPair(2, 20));
m.insert(IntPair(1, 10));
m.insert(IntPair(3, 30));

for (iter = m.begin(); iter != m.end(); ++iter)
cout << iter->first << ' ' << iter->second << '\t';

cout << endl;
return 0;
}